﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		AsyncCallContext.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            AsyncCallContext.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using System.Collections.Generic;
using Dexter.Async.CallContext;

namespace Dexter.CallContext.Async {

	/// <summary>
	/// This class is the implementation of ICallContext
	/// </summary>
	public class AsyncCallContext : IAsyncCallContext
	{
		#region ICallContext Members

		[ThreadStatic]
		private static Dictionary<String, Object> customTls;

		private static Dictionary<String, Object> CustomTls
		{
			get { return customTls ?? (customTls = new Dictionary<string, object>()); }
		}

		/// <summary>
		/// Gets the items.
		/// </summary>
		/// <value>The items.</value>
		public object this[string key]
		{
			get
			{
				Object retvalue;
				if (!CustomTls.TryGetValue(key, out retvalue))
				{
					return null;
				}
				return retvalue;
			}
			set { CustomTls[key] = value; }
		}

		#endregion
	}
}
